package leetcode100;

// TODO 动态规划 | 状态转移方程 [经典] 【-】 爬楼梯
// TODO https://leetcode.cn/problems/climbing-stairs/solution/hua-jie-suan-fa-70-pa-lou-ti-by-guanpengchn/

public class lc100_0070 {

    public int climbStairs(int n) {
        if (n == 1)
            return 1;

        int[] dp = new int[n];
        // 初始状态
        dp[0] = 1;
        dp[1] = 2;

        // 状态转移方程
        for (int i=2; i<n; i++) {
            dp[i] = dp[i-1] + dp[i-2];
        }
        return dp[n-1];
    }

}
